package com.quectel.core.module.household.dto.datav;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;

import java.io.Serializable;
import java.util.List;

/**
 * 人员统计
 *
 * @author caolu
 * @email louis.cao@quectel.com
 */
@Data
@Schema
public class HouseholdCountDto implements Serializable {

    @Schema(description = "人口总数")
    private Integer total;

    @Schema(description = "常住人口")
    private Integer residentPopulationCount;

    @Schema(description = "流动人口")
    private Integer transientPopulationCount;

    @Schema(description = "重点人群数量")
    private Integer focusGroupsCount;

    @Schema(description = "男性数量")
    private Integer maleCount;

    @Schema(description = "女性数量")
    private Integer femaleCount;

    @Schema(description = "年龄段分布列表")
    private List<AgeSegmentCls> ageSegments;

    @Data
    @Schema
    public static class AgeSegmentCls{
        @Schema(description = "段类型 0为未知 1为小于7岁 2为7-17岁 3为18-40岁 4为41-55岁 5为56-65岁 6为65岁以上")
        private Byte segmentType;
        @Schema(description = "段描述")
        private String segmentDesc;
        @Schema(description = "个数")
        private Integer count;
        @Schema(description = "占比")
        private String ratio;
    }

    @AllArgsConstructor
    public static enum SegmentEnum{
        UNKNOWN((byte)0, "未知"),
        SEGMENT_1((byte)1, "小于7岁"),
        SEGMENT_2((byte)2, "7-17岁"),
        SEGMENT_3((byte)3, "18-40岁"),
        SEGMENT_4((byte)4, "41-55岁"),
        SEGMENT_5((byte)5, "56-65岁"),
        SEGMENT_6((byte)6, "65岁以上");
        @Getter
        private final Byte type;
        @Getter
        private final String desc;

        public static String getDescByCode(Byte code){
            for(SegmentEnum segmentEnum : SegmentEnum.values()){
                if(segmentEnum.getType().equals(code)){
                    return segmentEnum.getDesc();
                }
            }
            return null;
        }
    }
}
